Repository navigation
fix: honor options.requestTimeout in afdocs check - #175
Merged
Merged
Conversation
The check command built its runner options field by field and never read requestTimeout from the config file, so the CLI always used the 15000 ms default while the vitest helpers honored the configured value. Forward the config value, add a --request-timeout flag that overrides it, and reject 0 in both validators, since a zero timeout aborts every request. Correct the documented default from 30000 to 15000.
There was a problem hiding this comment.
🟡 Changes recommended
The request-timeout parser silently truncates inputs such as 1e4 and 1.5, bypassing validation and potentially causing requests to healthy servers to fail.
1 open issue
What changed in this PR
This PR fixes #169 by wiring configured request timeouts into afdocs check, aligning the CLI with the existing runner behavior.
Changes:
- Honors
options.requestTimeoutand adds a--request-timeoutoverride. - Requires timeouts of at least 1 ms in config and runner validation.
- Adds regression tests and corrects the documented default to 15000 ms.
| File | Description |
|---|---|
test/unit/validation.test.ts |
Tests timeout validation at 0 and 1 ms. |
test/unit/cli/check-command.test.ts |
Tests config passthrough, flag precedence, unset behavior, and zero rejection. |
src/validation.ts |
Enforces the 1 ms minimum for runner options. |
src/helpers/config.ts |
Enforces the same minimum in config files. |
src/cli/commands/check.ts |
Adds the timeout flag and forwards the selected value to the runner. |
docs/reference/config-file.md |
Corrects the timeout default and documents the minimum. |
docs/reference/cli.md |
Documents the new flag and timeout guidance. |
Review effort: Balanced
parseInt reads only the numeric prefix, so "1e4" became a 1 ms timeout and "1.5" passed the integer check. Convert with Number so the existing validator sees the real value and rejects anything that is not an integer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Closes #169.
afdocs checknow honorsoptions.requestTimeoutfrom the config file. The command built its runner options field by field and never read this one, so the CLI always used the 15000 ms default while the vitest helpers honored the configured value.--request-timeout <ms>flag, which overrides the config value like the other request flags.requestTimeoutof 0 in both the config loader andvalidateRunnerOptions. A zero timeout aborts every request immediately, so the minimum is now 1.30000to15000(the code default has always been 15000) and documents the new flag in the CLI reference.Test plan
npx vitest run(2052 tests pass), including new CLI tests for the unset case, config passthrough, flag-over-config precedence, and rejection of--request-timeout 0requestTimeout: 1in the config now fails the fetches,--request-timeout 5000on top of that config lets them complete, and--request-timeout 0exits with a validation error